<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.staticfile.net/vue/2.7.8/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <h1>您的成绩评价</h1>
    <result :score="50"></result>
    <result :score="60"></result>
    <result :score="70"></result>
    <result :score="80"></result>
    <result :score="90"></result>
    <result :score="100"></result>
</div>
<script>
    Vue.component('result', {
        props: ['score'],
        template: `
          <div>
          <strong>{{ score }}分，{{ testResult }}</strong>
          </div>`,
        computed: {
            testResult: function () {
                if (this.score < 60) {
                    return '不及格';
                }
                if (this.score <= 90) {
                    return '中等生';
                }
                if (this.score == 100) {
                    return "优秀生";
                }
            }
        }
    })
    const vm = new Vue({
        el: '#app'
    });
</script>
</body>
</html>